<?php
namespace Admin\Controller;
use Think\Controller;
class LoginController extends Controller {
    public function index(){
        $this->display();
    }


    public function checkdata()
    {
    	$data = I('post.');

    	$username = $data['username'];
    	$password = md5($data['password']);

    	$user = M('admin')->where(['username'=>$username,'password'=>$password])->find();

    	if($user){

    		$_SESSION['aid']= $user['aid'];
    		$_SESSION['username']= $user['username'];
    		$this->ajaxReturn(['error'=>0,'info'=>"登录成功"]);
    	}else{
    		$this->ajaxReturn(['error'=>1,'info'=>"邮箱或者密码不正确"]);
    	}
    }

    public function logout()
    {
        #session_unset();
        session_destroy();
        $this->success('退出成功', U('admin/login/index'));
    }
}